<!DOCTYPE html>
<html>
<head>



    <template file="Home/meta" />
    <template file="Home/css" />






</head>
<body style="background:#fafafc">
<template file="Home/Cart/nav" />



<if condition="$logs">






    <div class="am-cf cart-list am-padding-0 am-margin-top-sm">

        <volist name="logs" id="v">

            <div class=" am-g cart-list-item common-border-bottom  am-margin-vertical-sm  common-border-top common-border-bottom ">


                <div class="am-u-sm-4 am-text-center  list_img"><img src="{$v.thumb}" class="am-img-responsive"></div>
                <div class="am-u-sm-5 am-text-xs">




                    <a href="{:U('Home/Product/show',array('id'=>$v['product_id']))} " class="">
                        <h3 class="am-margin-0">
                        {$v.title}</h3>
                        <div class="sku am-text-999" >

                            颜色分类:{$v.color};尺码: {:F('Var_chicun')[$v["chicun"]][name]}:外框: {:F('Var_waikuang')[$v["waikuang"]][name]}</div>
                    </a>







                </div>


                <div class="am-u-sm-3 am-text-right">





                    <div class="pay am-margin-top-sm am-cf div_info " >


                        <div class="">

                            <span class="am-text-danger am-text-sm"> ￥ <span id="price-{$key}">{$v.price}</span></span>




                        </div>
                        <div class=" ">x{$v.num}</div>



                    </div>



                </div>




                </div>

        </volist>


    </div>







<else/>



    <div class=" am-text-center  am-margin-vertical-lg am-padding-vertical-lg">


        <p>暂无关注记录</p>


        <a href="/Product/index" class=" btn-write am-padding-xs am-padding-horizontal-lg">去逛逛</a>


    </div>


    </if>



<div data-am-widget="navbar" class="am-navbar am-cf am-navbar-index  common-border-top "
     id="" >

    <template file="Home/bottom_nav" />
</div>



<template file="Home/js" />

<script>



    $(function(){

//        var sum=0;
//
//        $("input[type='text']").each(function(i){
//            sum = sum + parseInt($(this).val());
//            alert(sum);
//
//        })

        function  s_check(){
            var sum=0;
            var sum_price=0;


            $(".cart-list [type='checkbox']:checked").each(function(){
//                $(this).hide();
                var v=$(this).val();

                num=$("input[name='product["+v+"]']").val();


                price=parseInt($("#price-"+v+"").html());


                sum_price=sum_price+price*num;


            })



            $("#z_price").html("￥:"+sum_price);



        }


        $(".cart-list").click(function(){



            s_check();




        })


        $("#all_check").click(function () {



            $(".cart-list").find("input[type='checkbox']").uCheck('check');


        })

        $(".cart-list").find("input[type='checkbox']").click(function () {

            $("#all_check").uCheck('uncheck');

        })

        $("#edit_do").click(function () {

            $(this).addClass("am-hide");

            $(".div_edit").removeClass("am-hide");
            $(".div_info").addClass("am-hide");

            $("#wancheng").removeClass("am-hide");

            return false;

        })

    })


    //plugin bootstrap minus and plus
    //http://jsfiddle.net/laelitenetwork/puJ6G/
    $('.btn-number').click(function(e){
        e.preventDefault();

        fieldName = $(this).attr('data-field');
        type      = $(this).attr('data-type');
        var input = $("input[name='"+fieldName+"']");
        var currentVal = parseInt(input.val());
        if (!isNaN(currentVal)) {
            if(type == 'minus') {

                if(currentVal > input.attr('min')) {
                    input.val(currentVal - 1).change();
                }
                if(parseInt(input.val()) == input.attr('min')) {
                    $(this).attr('disabled', true);
                }

            } else if(type == 'plus') {

                if(currentVal < input.attr('max')) {
                    input.val(currentVal + 1).change();
                }
                if(parseInt(input.val()) == input.attr('max')) {
                    $(this).attr('disabled', true);
                }

            }
        } else {
            input.val(0);
        }




    });
    $('.input-number').focusin(function(){
        $(this).data('oldValue', $(this).val());
    });
    $('.input-number').change(function() {
        s_check();
        minValue =  parseInt($(this).attr('min'));
        maxValue =  parseInt($(this).attr('max'));
        valueCurrent = parseInt($(this).val());

        name = $(this).attr('name');
        if(valueCurrent >= minValue) {
            $(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled')
        } else {
            alert('Sorry, the minimum value was reached');
            $(this).val($(this).data('oldValue'));
        }
        if(valueCurrent <= maxValue) {
            $(".btn-number[data-type='plus'][data-field='"+name+"']").removeAttr('disabled')
        } else {
            alert('Sorry, the maximum value was reached');
            $(this).val($(this).data('oldValue'));
        }


    });
    $(".input-number").keydown(function (e) {
        // Allow: backspace, delete, tab, escape, enter and .
        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
                    // Allow: Ctrl+A
                (e.keyCode == 65 && e.ctrlKey === true) ||
                    // Allow: home, end, left, right
                (e.keyCode >= 35 && e.keyCode <= 39)) {
            // let it happen, don't do anything
            return;
        }
        // Ensure that it is a number and stop the keypress
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    });
</script>

</body>
</html>